package com.design.pattern.chainOfResponsibility;

public abstract  class AbstractHandler implements GateWayHandler{

    protected GateWayHandler gateWayHandler;

    public void setNextGateWayHandler(GateWayHandler nextGateWayHandler) {
        this.gateWayHandler=nextGateWayHandler;
    }


    @Override
    public void execute()  {
        //每一关只执行自己的方法，下一关放到抽象基类去
        service();
        if(gateWayHandler!=null){
            gateWayHandler.execute();
        }
    }

    /**
     * 真正服务的方法
     */
    public abstract void service();

}
